import React, { Component} from 'react'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
import * as utils from '@/utils/index.js'
import { bindActionCreators } from 'redux'
import actionsC from '@/store/actions.js'

let nodeActions=actionsC()

class UserConfig extends Component {
	constructor(props) {
        super(props);
        this.state={
            config:"{}"
        }
	}
	componentWillReceiveProps(nextProp){
	}
	componentDidMount(){
        let config = fs.readFileSync(`${__dirpath}/user-config.json`, 'utf8')
        this.setState({
            config:config
        })
    }
    handleChange(e){
        this.setState({
            config:e.target.value
        })
    }
	render() {
        let {config}=this.state
		return (
            <div className="user-config" id="user-config" ref="user-config" >
                <textarea
                    className="l-editor"
                    onChange={this.handleChange.bind(this)}
                    value={config}
                />
			</div>
		)
	}
}

UserConfig.defaultProps = {
};

function mapStateToProps(state) {
	return {
	}
}

function mapDispatchToProps(dispatch) {
	return {
		dispatch: bindActionCreators(nodeActions, dispatch)
	}
}

export default connect(
	mapStateToProps,
	mapDispatchToProps
)(UserConfig)

